﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Twin
{
    public partial class frmOption : Form
    {
        private int iPackSize;
        private int iGapBetweenPacks;

        public frmOption()
        {
            InitializeComponent();
        }

        private void frmOption_Load(object sender, EventArgs e)
        {
            string sPackSize = OperateIniFile.ReadIniData("OptionSensor", "PackSize_Bytes", "", ConfigIO.SensorMonitor_ini);
            iPackSize = Convert.ToInt32(sPackSize);
            string sGapBetweenPacks = OperateIniFile.ReadIniData("OptionSensor", "GapBetweenPacks_Ms", "", ConfigIO.SensorMonitor_ini);
            iGapBetweenPacks = Convert.ToInt32(sGapBetweenPacks);

            txtPackSize.Text = iPackSize.ToString();
            txtGapBtwPack.Text = iGapBetweenPacks.ToString();

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            frmOption.ActiveForm.Hide();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            //AutoFrame
            if (chkAutoFrame.Checked == true){
                OperateIniFile.WriteIniData("General", "AutoFrame", "1", ConfigIO.SensorMonitor_ini);
            }
            else{
                OperateIniFile.WriteIniData("General", "AutoFrame", "0", ConfigIO.SensorMonitor_ini);
            }

            OperateIniFile.WriteIniData("OptionSensor", "PackSize_Bytes",txtPackSize.Text, ConfigIO.SensorMonitor_ini);
            OperateIniFile.WriteIniData("OptionSensor", "GapBetweenPacks_Ms",txtGapBtwPack.Text, ConfigIO.SensorMonitor_ini);
            //OperateIniFile.WriteIniData("OptionSensor", "DefaultSensorEcho", SensorSim., ConfigIO.SensorSim_ini);
        }
    }
}
